package selcoursesys;

import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.ServletActionContext;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Lpbdz on 2017/4/9.
 */
public class LoginAction extends ActionSupport{
    private String username;
    private String password;
    private String usertype;

    public String getUsertype() {
        return usertype;
    }

    public void setUsertype(String usertype) {
        this.usertype = usertype;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String execute() throws Exception{
        return SUCCESS;
    }

    @Override
    public void validate(){
        if(getUsername()==null||"".equals(getUsername().trim())){
            this.addFieldError("usernameMsg","用户名不能为空");
        }
        if(this.getPassword().trim().length()==0){
            this.addFieldError("passwordMsg","密码不能为空");
        }
        if(getUsertype()==null){
            this.addFieldError("usertypeMsg","用户类型不能为空");
        }

    }
}
